import { fileURLToPath, URL } from 'node:url'

import { defineConfig, loadEnv } from 'vite'
import cesium from 'vite-plugin-cesium';
import vue from '@vitejs/plugin-vue'
// https://vitejs.dev/config/
export default defineConfig(({ command, mode }) => {
  const config = loadEnv(mode, './')
  return {
    plugins: [
      vue(),
      cesium()
    ],
    resolve: {
      alias: {
        '@': fileURLToPath(new URL('./src', import.meta.url))
      }
    },
    css: {
      preprocessorOptions: {
        scss: {
          additionalData: `@import "@/assets/css/config.scss";`, //设置全局变量（字号、颜色）
        },
      },
    },
    // server: {
    //   host: '0.0.0.0',
    //   port: 8080,
    //   open: false,
    //   cors: true,
    //   proxy: {
    //     '/goApi': {
    //       target: config.VITE_BASE_URL,  //从环境变量中获取地址
    //       changeOrigin: true,         //是否允许跨域
    //       rewrite: (path) => path.replace(/^\/goApi/, '')
    //     }
    //   }
    // },

  }
})
